/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.panpf.sketch.sample.widget.page;

import me.panpf.sketch.Sketch;
import me.panpf.sketch.SketchImageView;
import me.panpf.sketch.display.TransitionImageDisplayer;
import me.panpf.sketch.process.ReflectionImageProcessor;
import me.panpf.sketch.sample.AssetImage;
import me.panpf.sketch.sample.ResourceTable;
import me.panpf.sketch.sample.util.ResUtils;
import me.panpf.sketch.sample.widget.SampleImageView;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.app.Context;

/**
 * ReflectionImageProcessorTestPageView
 */
public class ReflectionImageProcessorTestPageView extends AbstractPageView {
    public ReflectionImageProcessorTestPageView(Context Context, String name) {
        super(Context, name);
    }

    @Override
    public void initView() {
        DisplayAttributes attributes = DisplayManager.getInstance().getDefaultDisplay(context).get().getAttributes();

        setRootView(ResUtils.parseLayout(context, ResourceTable.Layout_reflection_image_processor_page_view));

        SketchImageView sampleImageView = (SketchImageView) getRootView().findComponentById(ResourceTable.Id_sampleImageView);
        sampleImageView.getOptions().setMaxSize(attributes.width / 2, attributes.height / 2);
        sampleImageView.getOptions().setProcessor(new ReflectionImageProcessor());
        Sketch.with(getContext()).displayFromResource(ResourceTable.Media_mei_nv, sampleImageView).commit();
    }
}
